package com.hzbank.juc.introduction;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2023/12/18 - 15:45
 */
@Slf4j
public class Sleep02Interrupe {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = ()->{
            log.debug("enter sleep...");
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {

                log.debug("老子施法被打断了，超");
                throw new RuntimeException(e);
            }
        };
        Thread thread = new Thread(runnable, "t1");
        thread.start();
        TimeUnit.SECONDS.sleep(1);
        thread.interrupt();
    }
}
